package com.dawnClass.config;

import com.dawnClass.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {
//    @Autowired
//    private LoginInterceptor loginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        拦截course下所有页面
//        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/course/**");
//        取消对/index /course的拦截
//        excludePathPatterns ("/index");


        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/course/**")
                .addPathPatterns("/learn/**")
                .addPathPatterns("/community/**")
                .excludePathPatterns("/**/**.js")
                .excludePathPatterns("/**/**.css")
                .excludePathPatterns("/**/**.jsp")
                .excludePathPatterns("/**/**.jpg")
                .excludePathPatterns("/**/**.png")
                .excludePathPatterns("/**/**.html")
                .excludePathPatterns("/**/**.gif")
                .excludePathPatterns("/course")
                .excludePathPatterns("/logout")
                .excludePathPatterns("/community**")
                .excludePathPatterns("/community/article/**")
                .excludePathPatterns("/getCourse/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/index")
                .excludePathPatterns("/consumer")
                .excludePathPatterns("/publickey1")
                .excludePathPatterns("/encrypted1")
                .excludePathPatterns("/encrypted")
                .excludePathPatterns("/publickey");

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
